package com.lc.jpa;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "t_users")
@EntityListeners(UsersListener.class)
public class Users implements Serializable {

	private static final long serialVersionUID = 5552545868507187610L;

	@PrePersist
	private void beforeSave() {
		System.out.println("持久化前调用方法,保存的用户名为:" + name);
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private int userID;

	@Column(name = "t_name")
	private String name;

	/**
	 * 不持久化
	 */
	@Transient
	private String pwd;

	public int getUserID() {
		return userID;
	}

	public void setUserID(int userID) {
		this.userID = userID;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

}
